import sys
from pathlib import Path

base_path = str(Path(__file__).resolve().parent.parent)
sys.path.append(base_path)
from pydantic import BaseModel, Field
from langchain.tools import Tool
from create_llm import create_llm

# class Add(BaseModel):
#     "两个数字相加"

#     a: float = Field(description="两个数字相加第一个参数")
#     b: float = Field(description="两个数字相加第二个参数")

#     @staticmethod
#     def run(a, b):
#         return a + b


# class Minus(BaseModel):
#     "两个数字相减"

#     a: float = Field(description="两个数字相减第一个参数")
#     b: float = Field(description="两个数字相减第二个参数")

#     @staticmethod
#     def run(a, b):
#         return a - b
# tools = [
#     Tool.from_function(
#         name=Add.__name__, description=Add.__doc__, func=Add.run, args_schema=Add
#     ),
#     Tool.from_function(
#         name=Minus.__name__,
#         description=Minus.__doc__,
#         func=Minus.run,
#         args_schema=Minus,
#     ),
# ]


class Add:
    "两个数字相加"

    @staticmethod
    def run(a, b):
        return a + b


class Minus:
    "两个数字相减"

    @staticmethod
    def run(a, b):
        return a - b


tools = [
    Tool.from_function(name=Add.__name__, description=Add.__doc__, func=Add.run),
    Tool.from_function(
        name=Minus.__name__,
        description=Minus.__doc__,
        func=Minus.run,
    ),
]


tool_chain = create_llm(code="deepseek").bind_tools(tools)
result = tool_chain.invoke("2加3等于多少")
# print(type(result), "\n")
# print(result)
print(result.tool_calls)
